package com.cat.combination;

/**
 * @author cat
 * @version 2025/5/23 17:47
 * @description 菜单组件 (抽象根节点)
 * @since JDK17
 */

public abstract class MenuComponent {
    // 菜单组件的名称
    protected String name;
    // 菜单组件的层级
    protected int level;
    // 添加子菜单
    public void add(MenuComponent menuComponent) {
        throw new UnsupportedOperationException();
    }

    public MenuComponent() {
    }

    public MenuComponent(String name, int level) {
        this.name = name;
        this.level = level;
    }

    // 移除子菜单
    public void remove(MenuComponent menuComponent) {
        throw new UnsupportedOperationException();
    }

    // 获取指定子菜单
    public MenuComponent getChild(int index) {
        throw new UnsupportedOperationException();
    }

    // 获取菜单或菜单项的名称
    public String getName() {
        return name;
    }

    // 打印菜单和菜单项的名称(包含子)
    public abstract void print();
}
